package learn.spring.task;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import learn.spring.Timer;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

/**
 * 定时任务
 *  
 * @author PinWei Wan
 * @since 2.6.9
 */
@Slf4j
@Component
public class ScheduledTask1 {
    /**
     * 异步的定时任务
     */
    @SneakyThrows
    @Async
    @Scheduled(cron = "0/1 * * * * ? ")
    public void task() {
        // 模拟业务处理
        long cost = Timer.mock();

        log.info("定时任务[{}]运行完成, 耗时{}毫秒", this.getClass().getSimpleName(), cost);
    }
}
